﻿using System.Collections.Generic;
using Algoritmia.DataStructures.PriorityMaps;

namespace Algoritmia.DataStructures.DoubleEndedPriorityMaps
{
    public interface IDoubleEndedPriorityMap<TKey,TValue> : IPriorityMap<TKey,TValue>
    {
        KeyValuePair<TKey, TValue> GetWorst();
        KeyValuePair<TKey, TValue> ExtractWorst();
    }

    public static class DoubleEndedPriorityMapsExtensions
    {
        public static TKey GetWorstKey<TKey, TValue>(this IDoubleEndedPriorityMap<TKey, TValue> doubleEndedPriorityMap)
        {
            return doubleEndedPriorityMap.GetWorst().Key;
        }

        public static TValue GetWorstValue<TKey,TValue>(this IDoubleEndedPriorityMap<TKey,TValue> doubleEndedPriorityMap)
        {
            return doubleEndedPriorityMap.GetWorst().Value;
        }

        public static TKey ExtractWorstKey<TKey, TValue>(this IDoubleEndedPriorityMap<TKey, TValue> doubleEndedPriorityMap)
        {
            return doubleEndedPriorityMap.ExtractWorst().Key;
        }

        public static TValue ExtractWorstValue<TKey, TValue>(this IDoubleEndedPriorityMap<TKey, TValue> doubleEndedPriorityMap)
        {
            return doubleEndedPriorityMap.ExtractWorst().Value;
        }

        public static TKey GetOptimalKey<TKey, TValue>(this IDoubleEndedPriorityMap<TKey, TValue> doubleEndedPriorityMap)
        {
            return doubleEndedPriorityMap.GetOptimal().Key;
        }

        public static TValue GetOptimalValue<TKey, TValue>(this IDoubleEndedPriorityMap<TKey, TValue> doubleEndedPriorityMap)
        {
            return doubleEndedPriorityMap.GetOptimal().Value;
        }

        public static TKey ExtractOptimalKey<TKey, TValue>(this IDoubleEndedPriorityMap<TKey, TValue> doubleEndedPriorityMap)
        {
            return doubleEndedPriorityMap.ExtractOptimal().Key;
        }

        public static TValue ExtractOptimalValue<TKey, TValue>(this IDoubleEndedPriorityMap<TKey, TValue> doubleEndedPriorityMap)
        {
            return doubleEndedPriorityMap.ExtractOptimal().Value;
        }
    }
}
